package com.hackcloud.shardingjdbc.aop;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class DynamicDataSourceAop {

    @Pointcut("@annotation(com.hackcloud.shardingjdbc.aop.ShardingDataSource)")
    public void pointcut() {
    }

//    @Around("pointcut()")
//    public Object around(ProceedingJoinPoint pjp) throws Throwable {
//        MethodSignature methodSignature = (MethodSignature) pjp.getSignature();
//        Method targetMethod = methodSignature.getMethod();
//        if (targetMethod.isAnnotationPresent(ShardingDataSource.class)) {
//            DynamicDataSourceHolder.setDataSourceType(DynamicDataSourceHolder.DataBaseType.SHARDING_DATA_SOURCE);
//            System.out.println("----------数据源是:" + DynamicDataSourceHolder.getDataSourceType() + "------");
//        }
//        Object result = pjp.proceed();//执行方法
//        DynamicDataSourceHolder.clear();
//        return result;
//    }

}
